<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String corpId = (String)request.getAttribute("corpId");
    String corpSecret = (String)request.getAttribute("corpSecret");
%>
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>我的课程</title>
    <link href="../../lib/dropload/dropload.css" rel="stylesheet"/>
    <link rel="stylesheet" href="/lib/layui/layui/css/layui.css">
    <script type="text/javascript" src="../../js/jquery/jquery.min.js"></script>
    <script type="text/javascript" src="../../js/base/base.js"></script>
    <script type="text/javascript" src="../../js/ewx/waterMark.js?20190819.2"></script>
    <link href="../../css/H5/default.css" rel="stylesheet"/>
    <script type="text/javascript" src="../../lib/dropload/dropload.js"></script>
    <script src="/lib/layui/layui/layui.js"></script>
</head>
<style>
    /*video{*/
    /*    width: 100%;*/
    /*    height: 200px;*/
    /*}*/
    .item {
        margin-top: 20px;
    }
    .item h2{
        height: 40px;
        line-height: 40px;
        background:#f2f2f2;
        padding-left: 10px;
        box-sizing: border-box;
    }
    .conent{
        font-size: 14px;
        text-indent: 2em;
        margin: 10px;
        line-height: 24px;
    }
    .Introduction{
        font-size: 14px;
        text-indent: 2em;
        margin: 10px;
        line-height: 24px;
    }
    .detail{
        margin-left: 10px;
        height: 25px;
        line-height: 25px;
    }
</style>
<body>
<div>
    <div class="Play">

    </div>
    <div class="item">
        <h2>课程介绍</h2>
        <div class="Introduction"></div>
        <h2>内容目录</h2>
        <div class="conent"></div>
        <div id="con">

        </div>
    </div>
</div>
</body>
</html>
<script>
    //地址取值
    function getQueryString(name){
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r!=null)return  unescape(r[2]); return null;
    }
    var courseStage = getQueryString('id')
    //线上课程详情显示
    $.ajax({
        url: '/trCourse/showDetils',
        data: {courseId:courseStage},
        type: 'get',
        dataType: 'json',
        success:function (res) {
            if(res.msg !='err'){
                var data = res.object
                $('.Introduction').html(data.courseIntroduce)
                $('.conent').html(data.courseName)

                $('.Play').html('<video style="width: 100%; height=100%" id="myVideo" autoplay webkit-playsinline="true" controls>' +
                    ' <source src="'+data.videoAddress+'" type="video/mp4" x5-video-player-fullscreen="true" webkit-playsinline="true">' +
                    '</video>'+
                    '<button class="layui-btn layui-btn-sm" lay-event="add" style="width: 70px" onclick="detail()">结束学习</button>'

                );
                
                var str='';
                str +='<ul class="list">'+function(){
                    var str2=''
                    for(var j=0;j<data.attachmentList1.length;j++){
                        str2+='<li ><a style="color:#207BD6;padding-left: 38px; " href="javascript:;">'+cutOut(data.attachmentList1[j].name)+'</a><button class="layui-btn layui-btn-sm detail" name="'+data.attachmentList1[j].attachName+'" onclick="anios($(this))" url="' + location.protocol + '//' + location.host + '/download?'+ data.attachmentList1[j].attUrl+'" type="'+function(){
                            if(GetFileExt(data.attachmentList1[j].attachName) == '.jpg' || GetFileExt(data.attachmentList1[j].attachName) == '.jpeg' || GetFileExt(data.attachmentList1[j].attachName) == '.png' || GetFileExt(data.attachmentList1[j].attachName) == '.PNG' || GetFileExt(data.attachmentList1[j].attachName) == '.JPG'||GetFileExt(data.attachmentList1[j].attachName) == '.pdf' || GetFileExt(data.attachmentList1[j].attachName) == '.PDF'){
                                return 'playDiv';
                            }else if(GetFileExt(data.attachmentList1[j].attachName) == '.mp4' || GetFileExt(data.attachmentList1[j].attachName) == '.rmvb' || GetFileExt(data.attachmentList1[j].attachName) == '.avi' || GetFileExt(data.attachmentList1[j].attachName) == '.ifo' || GetFileExt(data.attachmentList1[j].attachName) == '.wmv') {
                                return 'player';
                            }else if (GetFileExt(data.attachmentList1[j].attachName) == '.doc' || GetFileExt(data.attachmentList1[j].attachName) == '.docx' || GetFileExt(data.attachmentList1[j].attachName) == '.ppt' || GetFileExt(data.attachmentList1[j].attachName) == '.pptx' || GetFileExt(data.attachmentList1[j].attachName) == '.xls'|| GetFileExt(data.attachmentList1[j].attachName) == '.xlsx') {
                                return 'seeDiv';
                            }else {
                                return 'downloadDiv';
                            }
                        }()+'"  style="width: 70px" >'+function(){
                            if(GetFileExt(data.attachmentList1[j].attachName) == '.jpg' || GetFileExt(data.attachmentList1[j].attachName) == '.jpeg' || GetFileExt(data.attachmentList1[j].attachName) == '.png' || GetFileExt(data.attachmentList1[j].attachName) == '.PNG' || GetFileExt(data.attachmentList1[j].attachName) == '.JPG'||GetFileExt(data.attachmentList1[j].attachName) == '.pdf' || GetFileExt(data.attachmentList1[j].attachName) == '.PDF'){
                                return '查看';
                            }else if(GetFileExt(data.attachmentList1[j].attachName) == '.mp4' || GetFileExt(data.attachmentList1[j].attachName) == '.rmvb' || GetFileExt(data.attachmentList1[j].attachName) == '.avi' || GetFileExt(data.attachmentList1[j].attachName) == '.ifo' || GetFileExt(data.attachmentList1[j].attachName) == '.wmv') {
                                return '查看';
                            }else if(GetFileExt(data.attachmentList1[j].attachName) == '.doc' || GetFileExt(data.attachmentList1[j].attachName) == '.docx' || GetFileExt(data.attachmentList1[j].attachName) == '.ppt' || GetFileExt(data.attachmentList1[j].attachName) == '.pptx' || GetFileExt(data.attachmentList1[j].attachName) == '.xls'|| GetFileExt(data.attachmentList1[j].attachName) == '.xlsx') {
                                return '查看';
                            }else{
                                return '下载';
                            }
                        }()+'</button></li>'
                    }
                    return str2;
                }()+'</ul>'
                $('#con').html(str)
                //监听播放开始
                var studyTimeNew=''
                var data={}

                // 设置开始时间
                studyTimeSum = new Date().Format('hh:mm:ss');
                // 设置是否增加次数类型
                countType = '1';

                // 设置定时器
                data.type=1;
                data.studyTime =180;
                data.courseId=courseStage;
                data.countType = countType;
                setInterval(function () {
                    $.ajax({
                        url:'/trCourseSchedule/addtrStudyRecord',
                        type:'post',
                        data:data,
                        dataType:'json',
                        success:function(res){
                            data.countType = '0';
                        }
                    })
                },180000)
            }
        }

    })
    //180000
    function cutOut(str) {
        if(str.charAt(str.length-1)=="*"){
            var arr = str.substring(0,str.length-1)
            return arr
        }
    }
    //返回的方法
    function detail(){
        startTime = new Date().Format('hh:mm:ss')
        endTime = new Date().Format('hh:mm:ss')
        $.ajax({
            url:'/trCourseSchedule/addtrStudyRecord',
            type:'post',
            data:{
                type:1,
                studyTimeSum:studyTimeSum,
                studyTimeNew:new Date().Format('hh:mm:ss'),
                courseId:courseStage,
                countType:countType
            },
            dataType:'json',
            success:function(res){
                window.location.href= '/train/courses';
            }
        })
    }
    function anios(e){
        var url = e.attr('url');
        var name = e.attr('name');
        if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
            try{
                window.webkit.messageHandlers.overLookFile.postMessage({'url':url,'name':name})
                // window.webkit.messageHandlers.overLookFile.postMessage({'url':url,'name':name});
            }catch(error){






                overLookFile(url,name);
            }
        } else if (/(Android)/i.test(navigator.userAgent)) {
            Android.overLookFile(url,name);
        }

    }
</script>